<?php

class News_model extends CI_Model {

    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    public function get_news() {
        //mysql_set_charset('latin1');
        $data = $this->db->query('select id, tieu_de, tom_tat from tin_tuc');
        return $data->result();
    }

    public function get_news_by_id($id="") {
        //mysql_set_charset('latin1');
        $data = $this->db->query('select tieu_de, tom_tat, noi_dung, ngay_dang from tin_tuc where id=' . $id);
        return $data->row();
    }
    function insert_news() {
        $data = array(
            'tieu_de' => $this->input->post('tieu_de'),
            'tom_tat' => $this->input->post('tom_tat'),
            'noi_dung' => $this->input->post('noi_dung'),
            'ngay_dang' => ''
        );
        $this->db->insert('tin_tuc', $data);
    }

}

?>
